const mutations = {
   

      SET_ADDTIME(state,val){
        state.counter =10;//一键换肤
      },
    SET_MYSHOW(state, val){
        state.myshow = true;//大小屏app下载显隐
     },
     SET_UNMYSHOW(state, val){
     state.myshow = true;
     },//大小屏app下载显隐
    SET_PLAY_MUSIC(state, val) {
        state.currentIndex = val.index,
            state.sequencePlayList = [...val.list], //歌单
            state.fullScreen = true,//打开大屏
            state.playing = true;//播放音乐
    },
    SET_SEQUENCEPLAYLIST(state, val) { //改变播放列表
        state.sequencePlayList = val
        localStorage.setItem("sequencePlayList", JSON.stringify(val));
    },
    SET_PLAY(state, val) { //播放
        state.playing = val
    },
    SET_STOPPLAY(state, val) { //暂停
        state.playing = val
    },
    SET_PLAY_MUSICINDEX(state, val) { //列表选择
        state.currentIndex = val.index
        state.playing = true;//播放音乐
    },
    SET_FULLSCREEN(state, val) { //大小屏切换
        state.fullScreen = val
    },
    SET_PLAYNEXT(state, val) { //下一首
        state.currentIndex = val
        state.playing = true;//播放音乐
    },
    SET_PREVIOUS(state, val) { //上一首
        state.currentIndex = val
        state.playing = true;//播放音乐
    },
    SET_ADDMUSIC(state, val) { //添加单曲播放
        const list = state.sequencePlayList
        for (let i = 0; i < list.length; i++) {
            const element = list[i];
            if (element.id == val.music.id) {
                state.currentIndex = i,
                    state.fullScreen = true//打开大屏
                state.playing = true;//播放音乐
                return
            }
        }
        state.sequencePlayList.push(val.music),
            state.currentIndex = state.sequencePlayList.length - 1,
            state.fullScreen = true,//打开大屏
            state.playing = true;//播放音乐
    },
    SET_CHANGE_MODE(state, val) { //切换播放模式
        state.mode = val
    },
    SET_PLAY_RAND(state, val) { //随机播放
        state.currentIndex = val,
            state.playing = true;//播放音乐
    },
    SET_HIGHLY(state, val) { //改变mini播放器的位置
        state.Highly = val
    },
    SET_CURRENTINDEX(state, val) { //设置索引
        state.currentIndex = val
        localStorage.setItem("currentIndex", JSON.stringify(val));
    },
    SET_STOPPLAY(state, val) {
        state.playing = false;//播暂停音乐
    },
    SET_ADDLIST(state, val) { //添加到播放列表
        state.playing = false;
    },
    SET_ADDLOVELIST(state, val) { //添加到喜欢列表
        state.likeList.push(val)
        localStorage.setItem("likeList", JSON.stringify(state.likeList))
    },
    SET_SLICEMUSIC(state, val) {//删除音乐
        state.likeList.splice(val, 1)
        localStorage.setItem("likeList", JSON.stringify(state.likeList))
    },
    SET_ATTSINGER(state, val) { //关注歌手
        state.attentionSingerList.push(val)
        localStorage.setItem("attentionSingerList", JSON.stringify(state.attentionSingerList))
    },
    SET_SLICESINGERS(state, val) {//删除歌手
        state.attentionSingerList.splice(val, 1)
        localStorage.setItem("attentionSingerList", JSON.stringify(state.attentionSingerList))
    },
    SET_PROGRESS(state, val) {//进度条
        state.progress = val
    },
    SET_LISSTENRECENTLY_SLICELIST(state, val) {//删除最近播放
        state.ListenRecently.splice(val, 1)
        localStorage.setItem("ListenRecently", JSON.stringify(state.ListenRecently))
    },
    SET_LISSTENRECENTLY(state, val) {//添加到最近播放
        state.ListenRecently.unshift(val)
        localStorage.setItem("ListenRecently", JSON.stringify(state.ListenRecently))
    },
    SET_LISSTENRECENTLY_SLICE(state, val) {//清空最近播放
        state.ListenRecently = []
        localStorage.setItem("ListenRecently", JSON.stringify(state.ListenRecently))
    },
    SET_LISSTENRECENTLY_SLICE_ITEM(state, val) {//清除item项
        state.ListenRecently.splice(val, 1)
        localStorage.setItem("ListenRecently", JSON.stringify(state.ListenRecently))
    },
    SET_SEARCH_HISTORY(state, val) {//搜索历史
        state.searchHistory.unshift(val)
        localStorage.setItem("searchHistory", JSON.stringify(state.searchHistory))
    },
    SET_SEARCH_HISTORY_SLICE(state, val) {//删除搜索历史
        state.searchHistory = []
        localStorage.setItem("searchHistory", JSON.stringify(state.searchHistory))
    },
    SET_PLAYNEXTARR(state, val) { //添加下一首播放
        state.sequencePlayList.splice(state.currentIndex + 1, 0, val)
    },
    SET_PLAYNEXTMOVEARR(state, val) { //添加下一首播放 列表中存在相同音乐
        if (state.currentIndex == 0) {
            state.currentIndex = 0
            let arr_temp = [].concat(state.sequencePlayList);  //创建一个新的临时数组，用以操作后不变更原数组
            arr_temp.splice(state.currentIndex + 1, 0, arr_temp.splice(val, 1)[0]);  //在b位置插入从a位置截取的元素
            state.sequencePlayList = arr_temp
            return
        } else if (val < state.currentIndex) {
            state.currentIndex = state.currentIndex - 1
            let arr_temp = [].concat(state.sequencePlayList);  //创建一个新的临时数组，用以操作后不变更原数组
            arr_temp.splice(state.currentIndex + 1, 0, arr_temp.splice(val, 1)[0]);  //在b位置插入从a位置截取的元素
            state.sequencePlayList = arr_temp
            return
        } else {
            let arr_temp = [].concat(state.sequencePlayList);  //创建一个新的临时数组，用以操作后不变更原数组
            arr_temp.splice(state.currentIndex + 1, 0, arr_temp.splice(val, 1)[0]);  //在b位置插入从a位置截取的元素
            state.sequencePlayList = arr_temp
            return
        }
    },
    SET_ADD_SONG_LIST(state, val) { //添加歌单
        state.songsList.push(val)
        localStorage.setItem("songsList", JSON.stringify(state.songsList))
    },
    SET_SONG_LIST_SLICE(state, val) { //删除歌单
        state.songsList.splice(val, 1)
        localStorage.setItem("songsList", JSON.stringify(state.songsList))
    },
    SET_CLOSE_NOTICEBAR(state, val) { //控制通知
        state.noticeBar = val
        localStorage.setItem("noticeBar", JSON.stringify(state.noticeBar))
    }
}

export default mutations